from utils import UtilsDriver,get_msg,get_data_json,get_data_xlsx_pandas
from page.page_home import HomeProxy
from page.page_login import LoginProxy
import unittest
from time import sleep
from ddt import ddt,data,unpack

# test_case_data=get_data_json('../data/login_case_data.json')
# test_case_data=get_data_xlsx_pandas('data/login_case_data.xlsx','test')
test_case_data=get_data_xlsx_pandas('data/login_case_data.xlsx','test')

@ddt
class TestLogin(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.home_proxy=HomeProxy()
        cls.login_proxy=LoginProxy()
        cls.home_proxy.go_login_page()

    def setUp(self):
        UtilsDriver.get_driver(url="http://hmshop-test.itheima.net/").refresh()

    @classmethod
    def tearDownClass(cls):
        UtilsDriver.quite_driver()

    # @pytest.mark.parametrize("username,password,code,expect",test_case_data)
    @data(*test_case_data)
    @unpack
    def test_login_all_ddt(self,username,password,code,expect):
        self.login_proxy.login(username, password, code)
        # 获取提示信息
        msg = get_msg()
        assert expect in msg

if __name__ == '__main__':
    unittest.main()
print("王梦雨")


